//
//  NearbyCell2.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/5/12.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "NearbyCell2.h"
#import "NearbyCellData.h"

@interface NearbyCell2()
@property (weak, nonatomic) IBOutlet UILabel *title;
@property (weak, nonatomic) IBOutlet UILabel *detailLab;
@property (weak, nonatomic) IBOutlet UIButton *img;

@end

@implementation NearbyCell2


+(instancetype)cellWithTableView:(UITableView *)tableView withData:(NearbyCellData *)data
{
    static NSString *ID = @"nearByCell2";
    NearbyCell2 *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell)
    {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"NearbyCell2" owner:nil options:nil]lastObject];
        [cell.detailLab setPreferredMaxLayoutWidth:UIScreenWidth - 2*10 - 10];
        [cell.detailLab layoutIfNeeded];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    }
    return cell;
}


-(void)setData:(NearbyCellData *)data
{
    self.title.text = data.title;
    self.detailLab.text = data.detail;
}

+(CGFloat)getHight:(NearbyCellData *)data withTableView:(UITableView *)tableView{
    
    static NearbyCell2 *cell = nil;
    
    static dispatch_once_t predicate; dispatch_once(&predicate, ^{
        
        cell = [NearbyCell2 cellWithTableView:tableView withData:data];
    });
    
    [cell setData:data];
    
    CGFloat height = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    
    return height+1;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
